import { http } from '@/utils/request'
import type {
  MaintenanceSkillAddRequest,
  MaintenanceSkillRemoveRequest,
  MaintenanceSkillQueryRequest,
  MaintenanceSkillResponse,
  UserSkillSummaryResponse,
  WorkOrderRecommendRequest,
  AiRecommendationResponse,
  SkillStatsResponse,
  BaseResponse,
  PageResponse
} from '@/types'

// 添加维修工技能
export const addMaintenanceSkill = (data: MaintenanceSkillAddRequest): Promise<BaseResponse<boolean>> => {
  return http.post('/skill/add', data)
}

// 移除维修工技能
export const removeMaintenanceSkill = (data: MaintenanceSkillRemoveRequest): Promise<BaseResponse<boolean>> => {
  return http.post('/skill/remove', data)
}

// 查询维修工技能列表
export const getMaintenanceSkillList = (data: MaintenanceSkillQueryRequest): Promise<BaseResponse<PageResponse<MaintenanceSkillResponse>>> => {
  return http.post('/skill/list', data)
}

// 获取所有维修工及其技能
export const getAllMaintenanceWorkers = (): Promise<BaseResponse<UserSkillSummaryResponse[]>> => {
  return http.post('/skill/all-maintenance-workers')
}

// 获取维修工技能汇总
export const getUserSkillSummary = (userId: number): Promise<BaseResponse<UserSkillSummaryResponse>> => {
  return http.get(`/skill/user/${userId}`)
}

// AI推荐维修人员
export const recommendMaintenanceWorkers = (data: WorkOrderRecommendRequest): Promise<BaseResponse<AiRecommendationResponse>> => {
  return http.post('/workorder/recommend-maintenance', data)
}

// 获取技能统计信息
export const getSkillStats = (): Promise<BaseResponse<SkillStatsResponse>> => {
  return http.post('/skill/stats')
}
